package cn.mldn.microcloud.receiver;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.stereotype.Component;

@Component
public class MqReceiver {

	//@RabbitListener(queuesToDeclare = @Queue("myQueue"))
	//自动创建队列，Exchange与queue绑定
	
	//根据队列接收消息
	@RabbitListener(bindings = @QueueBinding(
			exchange = @Exchange("myExchage"),
			value = @Queue("myQueue")			
			))
	public void Process(String message){
		System.out.println("myQueue MqReceiver message:"+message);
	}
	
	//根据exchange接收消息
	@RabbitListener(bindings = @QueueBinding(
			exchange = @Exchange("myExchage"),
			key ="add",
			value = @Queue("myAddQueue")			
			))
	public void addProcess(String message){
		System.out.println("addProcess MqReceiver message:"+message);
	}
	
/*	@RabbitListener(bindings = @QueueBinding(
			exchange = @Exchange("myExchage"),
			key ="update",
			value = @Queue("myUpdateQueue")			
			))
	public void updateProcess(String message){
		System.out.println("updateProcess MqReceiver message:"+message);
	}*/
}
